﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Data;
using CPPEI.Coolzon.Server.CacheData;
using CPPEI.Coolzon.Service.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Server.ServiceImplement
{
    /// <summary>
    /// 请求滚动场景处理
    /// </summary>
    public class ReqLoopSceneHandler : BaseHandler<ReqLoopSceneData, RespLoopSceneData>
    {
        public ReqLoopSceneHandler()
            : base(RESPONSE_SCENARIO.SCENE, RESPONSE_COMMAND.SCENE.LOOPSCENE)
        {
        }

        protected override RespLoopSceneData OnHandle(Data.MainServiceData.Request request, ReqLoopSceneData requestData)
        {
            CacheData.ControlDomain domain = CacheData.ServerData.Instance.GetDomain(request.Header.DomainId);
            if (domain != null)
            {
                domain.UpdateViewState(domain.SolutionName, requestData.ViewStateAge, requestData.ViewStateToken);

                RespLoopSceneData respLoopSceneData = new RespLoopSceneData();
                respLoopSceneData.Direction = requestData.Direction;
                respLoopSceneData.OffsetDelta = requestData.OffsetDelta;
                //respLoopSceneData.CurrentOffset = sceneState.HorizontalLoopOffset;
                respLoopSceneData.SceneName = requestData.SceneName;
                return respLoopSceneData;
            }

            return null;
        }
    }
}
